<?php
if (version_compare(phpversion(), '5.1.0', '<') == true) {
	die('Above PHP5.1 Only'); 
}


define('PROJECT_VERSION', '0.9');


define('LOCAL', '0');
#temporary constant to know where the application host
#at home or in company
define('COMPANY', 1);
define('DOCTRINE_SETUP', '0');

define('DIRSEP', DIRECTORY_SEPARATOR);

##################################################################
# CONFIGURATION FOR DATABASE CONNECTION STRING
# CONFIGURATION FOR HTTP SERVER
##################################################################
if (LOCAL == '1') {
	error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING);
	//error_reporting(E_ALL);
	ini_set("display_errors", "1");
	
	define('DB_SERVER', 'localhost');
	define('DB_SERVER_USERNAME', 'root');
	define('DB_SERVER_PASSWORD', '');
	define('DB_DATABASE', 'shopping');

	define('SERVER' , 'localhost:8080');	
	define('SERVER_PATH', '/ushop-beta1');
  
} else {
	//error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
	//error_reporting(E_ALL);
	//ini_set("display_errors", "0");
	ini_set("display_errors", "1");
	
	//define('DB_SERVER', 'localhost');
	define('DB_SERVER', 'localhost');
	define('DB_SERVER_USERNAME', 'root');
	define('DB_SERVER_PASSWORD', '');
	define('DB_DATABASE', 'phuhane1_ushop');
	
	define('SERVER' , 'localhost/ttl');
	define('SERVER_PATH', '');
}

// Define database connection for both
// Shopping cart packages and
// Doctrine
define('DSN', 'mysql:dbname=' . DB_DATABASE . ';host=' . DB_SERVER);
define('USER', DB_SERVER_USERNAME);
define('PASSWD', DB_SERVER_PASSWORD);

define('USE_PCONNECT', 'false');







define('HTTP_SERVER', 'http://' . SERVER);
define('HTTPS_SERVER', 'https://' . SERVER);

// Phu Ha
// Put it empty, it works!!?
// Will investigate why
define('HTTP_COOKIE_DOMAIN', '');
define('HTTPS_COOKIE_DOMAIN', '');


// Phu Ha
// It works now, but need to investigate later
/*define('HTTP_CATALOG_SERVER', HTTP_SERVER . SERVER_PATH);
define('HTTPS_CATALOG_SERVER', HTTPS_SERVER . SERVER_PATH);
*/
define('HTTP_CATALOG_SERVER', HTTP_SERVER);
define('HTTPS_CATALOG_SERVER', HTTPS_SERVER);





##################################################################
## CONFIGURATION FOR APPLICATION SERVER PATH
##################################################################

// Get Root Application Path
$global_root_path = realpath(dirname(__FILE__)  . DIRSEP . '..' . DIRSEP . '..' . DIRSEP) . DIRSEP;
//If using justhost, the root html folder is under public_html of master domain
//in this case, master domain is doanhnghiep20.net
//add-on domain is www3.ushop.vn so it is nested under public_html/www3ushop
define('GLOBAL_ROOT_HTML_FOLDER_NAME', '');

//normal case this is independent hosting just for ushop (anh Phu Nguyen hosting)
//define('GLOBAL_ROOT_HTML_FOLDER_NAME', 'public_html');


define('GLOBAL_ROOT_PATH', $global_root_path);
define('GLOBAL_ROOT_HTML', $global_root_path . GLOBAL_ROOT_HTML_FOLDER_NAME . DIRSEP);
define('GLOBAL_ROOT_DOCTRINE', $global_root_path . 'doctrine' . DIRSEP);
define('GLOBAL_ROOT_LOG4PHP', $global_root_path . 'log4php' . DIRSEP);
define('GLOBAL_ROOT_SMARTY', $global_root_path . 'smarty' . DIRSEP);
define('GLOBAL_ROOT_SMARTY_LIB', $global_root_path . 'smarty_lib' . DIRSEP);
define('GLOBAL_ROOT_INCLUDES', GLOBAL_ROOT_HTML . 'global' . DIRSEP . 'includes' . DIRSEP);
define('GLOBAL_ROOT_CLASSES', GLOBAL_ROOT_HTML . 'global' . DIRSEP . 'classes' . DIRSEP);

define('GLOBAL_PACKAGE_SHIPPING', GLOBAL_ROOT_HTML . 'shipping' . DIRSEP);
define('GLOBAL_PACKAGE_EMPTY', GLOBAL_ROOT_HTML . 'empty' . DIRSEP);
define('GLOBAL_PACKAGE_SHOPPING', GLOBAL_ROOT_HTML );


// Define Module/Package include
define('GLOBAL_MODULE_MVC', GLOBAL_ROOT_INCLUDES . 'mvc' . DIRSEP . 'mvc.php');

define('GLOBAL_MODULE_DOCTRINE', GLOBAL_ROOT_DOCTRINE . 'Doctrine.php');
define('GLOBAL_CONFIG_DOCTRINE', GLOBAL_ROOT_INCLUDES . 'doctrine.php');

define('GLOBAL_MODULE_SMARTY', GLOBAL_ROOT_SMARTY_LIB . 'Smarty.class.php');
define('GLOBAL_CONFIG_SMARTY', GLOBAL_ROOT_INCLUDES . 'smarty.php');

// Define Paths of Object Relationship Mapping DOCTRINE module
define('GLOBAL_MODULE_DOCTRINE_MODEL', GLOBAL_ROOT_HTML . 'global' . DIRSEP . 'model');
define('GLOBAL_MODULE_DOCTRINE_MODEL_BASE', GLOBAL_MODULE_DOCTRINE_MODEL . DIRSEP . 'generated');

// Define Paths of Smarty module
define('GLOBAL_MODULE_SMARTY_TEMPLATES', GLOBAL_ROOT_SMARTY . 'templates');
define('GLOBAL_MODULE_SMARTY_TEMPLATES_COMPILED', GLOBAL_ROOT_SMARTY . 'templates_c');
define('GLOBAL_MODULE_SMARTY_CACHE', GLOBAL_ROOT_SMARTY . 'cache');
define('GLOBAL_MODULE_SMARTY_CONFIGS', GLOBAL_ROOT_SMARTY . 'configs');


// Define Paths to Global-wide init and clean-up code
define('GLOBAL_APP_COMMON_TOP', GLOBAL_ROOT_INCLUDES . 'top.php');
define('GLOBAL_APP_COMMON_BOTTOM', GLOBAL_ROOT_INCLUDES . 'bottom.php');








######################################################################
## CONFIGURATION FOR SHOPPING CART - INCLUDING ONLINE & ADMIN MODULE
######################################################################


// Define SSL config for Admin Page
define('ENABLE_SSL_CATALOG', 'false');

// Define SSL config for Shopping Cart Page
define('ENABLE_SSL', false);



// Currently, whole Shopping Cart system using DIR_FS_DOCUMENT_ROOT to get public_html
// so temporary set DIR_FS_DOCUMENT_ROOT to GLOBAL_ROOT_HTML
// but need to revise and change to GLOBAL_ROOT_HTML instead of DIR_FS_DOCUMENT_ROOT

// Below almost definition for ADMIN MODULE
// Define for Web Server paths of Admin module

define('DIR_WS_CATALOG', SERVER_PATH . '/');
define('DIR_WS_ADMIN', SERVER_PATH . '/admin/');


define('DIR_FS_DOCUMENT_ROOT', GLOBAL_PACKAGE_SHOPPING);
define('DIR_FS_CATALOG', DIR_FS_DOCUMENT_ROOT);
define('DIR_FS_ADMIN', DIR_FS_DOCUMENT_ROOT . 'admin/');


define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . 'images/');
define('DIR_WS_CATALOG_LANGUAGES', DIR_WS_CATALOG . 'includes/languages');

define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');
define('DIR_FS_CATALOG_LANGUAGES', DIR_FS_CATALOG . 'includes/languages/');


define('DIR_FS_CATALOG_MODULES', DIR_FS_CATALOG . 'includes/modules/');


define('DIR_WS_IMAGES', 'images/');
define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');


define('DIR_WS_INCLUDES', 'includes/');
define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');


define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');


// Below definition for SHOPPING CART MODULE

define('HTTP_COOKIE_PATH', SERVER_PATH . '/');
define('HTTPS_COOKIE_PATH', SERVER_PATH . '/');
define('DIR_WS_HTTP_CATALOG', SERVER_PATH . '/');
define('DIR_WS_HTTPS_CATALOG', SERVER_PATH . '/');


define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

  
  
 
 











##################################################################
## CONFIGURATION FOR STORING BROWSER SESSIONS
##################################################################

define('STORE_SESSIONS', 'mysql');
//define('STORE_SESSIONS', 'folder');












##################################################################
## CONFIGURATION FOR APPLICATION LOGGING MECHANISM
##################################################################
define('GLOBAL_LOGGER', GLOBAL_ROOT_LOG4PHP . 'Logger.php');
if (LOCAL == '1') {
	if (COMPANY == '1') {
		define('GLOBAL_LOGGER_CONFIG', GLOBAL_ROOT_INCLUDES . 'company.properties');
	} else {
		define('GLOBAL_LOGGER_CONFIG', GLOBAL_ROOT_INCLUDES . 'local_verbose.properties');	
	}		
} else {
	//production2 su dung cho moi truong hosting tren server anh Phu lon
	//duong dan den file ghi log phu thuoc theo hosting
	//define('GLOBAL_LOGGER_CONFIG', GLOBAL_ROOT_INCLUDES . 'production2_verbose.properties');
	
	//production3 dinh nghi duong dan ghi file log cho moi truong hosting tren justhost
	define('GLOBAL_LOGGER_CONFIG', GLOBAL_ROOT_INCLUDES . 'production3_verbose.properties');
}

////////////////////////////
// Log Mechanism
////////////////////////////
// 1. Log to HTML file for easy to download, and show up inside admin pages of Shopping Cart System
// 2. Log using daily rolled over, separate by date for easy to troubleshooting
// 3. There are 2 Log configuration files: 1 for local path, 1 for production server path.
// 4. Log Level all the time is to DEBUG on Production Server for easy to troubleshooting.
// But can be changed at LOCAL at any required LEVEL just for Developing and Debugging LOCAL

require_once GLOBAL_LOGGER;
Logger::configure(GLOBAL_LOGGER_CONFIG);


define('LOGGER_COMMON', 'COMMON');
define('LOGGER_CONSOLE', 'CONSOLE');
define('LOGGER_DOCTRINE', 'DOCTRINE');
define('LOGGER_SMARTY', 'SMARTY');
define('LOGGER_MVC', 'MVC');
define('LOGGER_SC_ADMIN', 'SC_ADMIN');

// Initiate GLOBAL LOGGERS
$GLOBAL_LOGGER_MVC = Logger::getLogger(LOGGER_MVC);
$GLOBAL_LOGGER_DOCTRINE = Logger::getLogger(LOGGER_DOCTRINE);
$GLOBAL_LOGGER_SMARTY = Logger::getLogger(LOGGER_SMARTY);




##################################################################
## CONFIGURATION FOR MVC MODEL
##################################################################

// Settings for MVC model
define('DEFAULT_CONTROLLER', 'DefaultController');
define('DEFAULT_ACTION', 'DefaultAction');

// Get directory of CONTROLLERS
define('CONTROLLERS_SHIPPING', GLOBAL_PACKAGE_SHIPPING . 'controllers' . DIRSEP);
define('CONTROLLERS_DEFAULT', GLOBAL_PACKAGE_EMPTY . 'controllers' . DIRSEP);
define('CONTROLLERS_CURRENT', CONTROLLERS_DEFAULT);

# This command will be executed by module after including global include
# and define the CURRENT_CONTROLLERS for that specific module
require_once GLOBAL_MODULE_MVC;



##################################################################
## CONFIGURATION FOR OBJECT RELATIONSHOP MAPPING MECHANISM
##################################################################

#require_once GLOBAL_CONFIG_DOCTRINE;





##################################################################
## CONFIGURATION FOR OBJECT RELATIONSHOP MAPPING MECHANISM
##################################################################
 
require_once GLOBAL_CONFIG_SMARTY;

































?>